<template>
  <el-table-column :prop="item.prop" :label="item.label" :width="item.width">
    <template #default="{ row }">
      <el-switch v-model="row[item.prop]" @change="handleClick({ handle: item.handle, row })" />
    </template>
  </el-table-column>
</template>

<script setup lang="ts">
  import { PropType, toRefs } from 'vue';

  import { ClickColumnType } from '../common-table-type';

  const props = defineProps({
    item: {
      type: Object as PropType<ClickColumnType>,
      default: () => ({ prop: '' }),
    },
  });

  const { item } = toRefs(props);

  const emits = defineEmits({
    handle: null,
  });

  const handleClick = (val: any) => {
    emits('handle', val);
  };
</script>

<style scoped></style>
